001 /** 002 * Created by IntelliJ IDEA. 003 * User: Wei Wang 004 * Date: Mar 11, 2003 005 * Time: 9:15:14 PM 006 */ 007 008 package EVolve.util.painters; 009 010 import EVolve.visualization.AutoImage; 011 import java.awt.*; 012 import java.util.*; 013 014 public class AllocDensityMetricPainter extends Painter{ 015 private long totalAlloc; 016 private long lastX; 017 private float max; 018 private HashMap values; 019 020 public AllocDensityMetricPainter() { 021 totalAlloc = 0; 022 lastX = 0; 023 max = 0; 024 values = new HashMap(); 025 } 026 027 public String getName() { 028 return "Metric Painter"; 029 } 030 031 public void paint(AutoImage image, long x, long y, long z) { 032 long bytecode = z; 033 if (lastX != x) { 034 for (long i = lastX; i<x; i++) 035 values.put(new Long(i),new Float((float)(1000*totalAlloc)/(float)bytecode)); 036 image.setColor((int)x,(int)(1000*totalAlloc/bytecode),Color.red); 037 lastX = x; 038 } 039 totalAlloc = y; 040 if (max < (float)(totalAlloc*1000)/(float)bytecode) { 041 max = (float)(totalAlloc*1000)/(float)bytecode; 042 } 043 } 044 045 public float getMax() { 046 return max; 047 } 048 049 public float getValue(int x) { 050 if (!values.containsKey(new Integer(x))) 051 return -1; 052 return ((Float)values.get(new Integer(x))).floatValue(); 053 } 054 }